package com.example.cardserver.service.impl;

import com.example.cardserver.entity.HeaNews;
import com.example.cardserver.mapper.HeaNewsMapper;
import com.example.cardserver.service.IHeaNewsService;
import com.example.cardserver.service.ex.HeaNewsException;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class HeaNewsServiceImpl implements IHeaNewsService {
    @Resource
    private HeaNewsMapper heaNewsMapper;
    
    @Override
    public List<HeaNews> listAllNews() {
        List<HeaNews> list = heaNewsMapper.findList();
        return list;
    }

    @Override
    public HeaNews findById(Integer id) {
        HeaNews news = heaNewsMapper.findById(id);
        if(news == null){
            throw new HeaNewsException("数据不存在");
        }
        return news;
    }
}
